﻿// ===============================================================================
//  Copyright © ymind.net. All rights reserved .
//  官方网站：http://ymind.net/
//  版权所有：彦铭工作室 老陈出品
// ===============================================================================

using System;
using Lcsoft.RssEngine.Collections;
using Lcsoft.RssEngine.Shared;

namespace Lcsoft.RssEngine.RssChannel
{
	/// <summary>Grouping of related content items on a site</summary>
	[Serializable]
	public class RssChannel : IRssElement
	{
		private string _copyright = String.Empty;
		private string _description = String.Empty;
		private string _docs = String.Empty;
		private string _generator = String.Empty;
		private string _language = String.Empty;
		private Uri _link = RssDefault.UriValue;
		private string _managingEditor = String.Empty;
		private string _rating = String.Empty;
		private int _timeToLive = RssDefault.IntValue;
		private string _title = String.Empty;
		private string _webMaster = String.Empty;

		/// <summary>
		/// 
		/// </summary>
		public RssChannel()
		{
			this.Items = new RssItemCollection();
			this.SkipHours = new bool[24];
			this.SkipDays = new bool[7];
			this.LastBuildDate = RssDefault.DateTimeValue;
			this.Categories = new RssCategoryCollection();
			this.PubDate = RssDefault.DateTimeValue;
		}

		/// <summary>The name of the channel</summary>
		/// <remarks>Maximum length is 100 characters (For RSS 0.91)</remarks>
		public string Title
		{
			get { return this._title; }
			set { this._title = RssDefault.Check(value); }
		}

		/// <summary>URL of the website named in the title</summary>
		/// <remarks>Maximum length is 500 characters (For RSS 0.91)</remarks>
		public Uri Link
		{
			get { return this._link; }
			set { this._link = RssDefault.Check(value); }
		}

		/// <summary>Description of the channel</summary>
		/// <remarks>Maximum length is 500 characters (For RSS 0.91)</remarks>
		public string Description
		{
			get { return this._description; }
			set { this._description = RssDefault.Check(value); }
		}

		/// <summary>Language the channel is written in</summary>
		public string Language
		{
			get { return this._language; }
			set { this._language = RssDefault.Check(value); }
		}

		/// <summary>A link and description for a graphic icon that represent a channel</summary>
		public RssImage Image { get; set; }

		/// <summary>Copyright notice for content in the channel</summary>
		/// <remarks>Maximum length is 100 (For RSS 0.91)</remarks>
		public string Copyright
		{
			get { return this._copyright; }
			set { this._copyright = RssDefault.Check(value); }
		}

		/// <summary>The email address of the managing editor of the channel, the person to contact for editorial inquiries</summary>
		/// <remarks>
		/// <para>Maximum length is 100 (For RSS 0.91)</para>
		/// <para>The suggested format for email addresses in RSS elements is</para>
		/// <para>bull@mancuso.com (Bull Mancuso)</para>
		/// </remarks>
		public string ManagingEditor
		{
			get { return this._managingEditor; }
			set { this._managingEditor = RssDefault.Check(value); }
		}

		/// <summary>The email address of the webmaster for the channel</summary>
		/// <remarks>
		/// <para>Person to contact if there are technical problems</para>
		/// <para>Maximum length is 100 (For RSS 0.91)</para>
		/// <para>The suggested format for email addresses in RSS elements is</para>
		/// <para>bull@mancuso.com (Bull Mancuso)</para>
		/// </remarks>
		public string WebMaster
		{
			get { return this._webMaster; }
			set { this._webMaster = RssDefault.Check(value); }
		}

		/// <summary>The PICS rating for the channel</summary>
		/// <remarks>Maximum length is 500 (For RSS 0.91)</remarks>
		public string Rating
		{
			get { return this._rating; }
			set { this._rating = RssDefault.Check(value); }
		}

		/// <summary>The publication date for the content in the channel, expressed as the coordinated universal time (UTC)</summary>
		public DateTime PubDate { get; set; }

		/// <summary>The date-time the last time the content of the channel changed, expressed as the coordinated universal time (UTC)</summary>
		public DateTime LastBuildDate { get; set; }

		/// <summary>One or more categories the channel belongs to.</summary>
		public RssCategoryCollection Categories { get; private set; }

		/// <summary>A string indicating the program used to generate the channel</summary>
		public string Generator
		{
			get { return this._generator; }
			set { this._generator = RssDefault.Check(value); }
		}

		/// <summary>A URL, points to the documentation for the format used in the RSS file</summary>
		/// <remarks>Maximum length is 500 (For RSS 0.91).</remarks>
		public string Docs
		{
			get { return this._docs; }
			set { this._docs = RssDefault.Check(value); }
		}

		/// <summary>Provides information about an HTTP GET feature, typically for a search or subscription</summary>
		public RssTextInput TextInput { get; set; }

		/// <summary>Readers should not read the channel during days listed. (UTC)</summary>
		/// <remarks>Days are listed in the array in the following order:<list type="number">
		/// <item><description>Monday</description></item>
		/// <item><description>Tuesday</description></item>
		/// <item><description>Wednesday</description></item>
		/// <item><description>Thursday</description></item>
		/// <item><description>Friday</description></item>
		/// <item><description>Saturday</description></item>
		/// <item><description>Sunday</description></item>
		/// <item><description>Monday</description></item>
		/// </list></remarks>
		public bool[] SkipDays { get; set; }

		/// <summary>Readers should not read the channel during hours listed (UTC)</summary>
		/// <remarks>Represents a time in UTC - 1.</remarks>
		public bool[] SkipHours { get; set; }

		/// <summary>Allow processes to register with a cloud to be notified of updates to the channel</summary>
		public RssCloud Cloud { get; set; }

		/// <summary>The number of minutes that a channel can be cached.</summary>
		public int TimeToLive
		{
			get { return this._timeToLive; }
			set { this._timeToLive = RssDefault.Check(value); }
		}

		/// <summary>All items within the channel</summary>
		public RssItemCollection Items { get; private set; }

		/// <summary>Returns a string representation of the current Object.</summary>
		/// <returns>The channel's title, description, or "RssChannel" if the title and description are blank.</returns>
		public override string ToString() { return this._title ?? (this._description ?? "RssChannel"); }
	}
}
